<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/5/25
  Time: 10:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

    <table>
    <thead>
    <tr>
    <td>编号</td>
    <td>姓名</td>
    <td>电话</td>
    <td>发起申请</td>
    </tr>
    </thead>
    <tbody>
<%

    //3+1
    Connection connection=null;
    Statement statement=null;
    ResultSet resultSet=null;
    String sql="SELECT id,username,TEL FROM t_users";
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/part_time_job?serverTimezone=UTC",
            "root",
            "123456"
    );

    statement = connection.createStatement();
    statement.execute(sql);

    out.write("statement.execute(sql)");

    statement.close();
    connection.close();

    class User{
        int id;
        String username;
        String password;
    }
    List<User> list=new ArrayList<User>();

    while (resultSet.next()){
        int id = resultSet.getInt(1);
        String username = resultSet.getString(2);
        String password = resultSet.getString(3);

        User u = new User();
        u.id=id;
        u.username=username;
        u.password=password;
        list.add(u);
    }
    resultSet.close();
    statement.close();
    connection.close();
//            list.add(chen);
    for (User user:list){
        out.write("<tr><td>"+user.id+ "</td>" +
                "<td>"+user.username+ "</td>" +
                "<td>"+user.password+ "</td>"+
                "<td><a href='replace.jsp'>申请</a></td>");
    }


%>


    </tbody>
    </table>
</body>
</html>
